<%@ page language="java" import="java.util.*" pageEncoding="utf8"%>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>数据字典</title>
<%
	String path = request.getContextPath();
	String rootPath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ "/";
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("basePath", basePath);
	request.setAttribute("rootPath", rootPath);
	pageContext.setAttribute("newLineChar", "\n");
%>
<script src="<%=basePath%>scripts/jquery-1.9.1.min.js"></script>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
</head>

<style type="text/css">
.datagrid-mask {
	background: #ccc;
}

.datagrid-mask-msg {
	border-color: #95B8E7;
}

.datagrid-mask-msg {
	background: #ffffff url('../images/loading.gif') no-repeat scroll 5px
		center;
}

.datagrid-mask {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	opacity: 0.3;
	filter: alpha(opacity = 30);
	display: none;
}

.datagrid-mask-msg {
	position: absolute;
	top: 50%;
	margin-top: -20px;
	padding: 12px 5px 10px 30px;
	width: auto;
	height: 16px;
	border-width: 2px;
	border-style: solid;
	display: none;
}

.list_table {
	border: 1px solid #CCCCCC;
	border-collapse: collapse;
	color: #333333;
	margin: 0 0 0;
	width: 100%;
}

.list_table tbody td {
	border-top: 1px solid #CCCCCC;
	text-align: left;
}

.list_table th {
	line-height: 1.2em;
	vertical-align: top;
	text-align:left;
	font-size: 12px;
	line-height: 2em;
	white-space: nowrap;
}

.list_table td {
	line-height: 2em;
	font-size: 12px;
	vertical-align: central;
	align: left;
	white-space: nowrap;
}

.list_table td input {
	width: 100px;
}

.list_table td input[name=jobId] {
	width: 50px;
}

.list_table tbody tr:hover th,.list_table tbody tr:hover td {
	background: #EEF0F2;
}

.list_table thead tr {
	background: none repeat scroll 0 0 #146C9C;
	color: #fff;
	font-weight: bold;
	border-bottom: 1px solid #CCCCCC;
	border-right: 1px solid #CCCCCC;
}
.list_head_li{
	list-style:none;
	padding: none;
	margin: none;
	float:left;
	margin-left: 50px;
	margin-bottom: 20px;
}
.list_head_li_a{
	display:block; /* 将链接设为块级元素 */
	width:150px; /* 设置宽度 */
	height:100px; /* 设置高度 */
	line-height:100px; /* 设置行高，将行高和高度设置同一个值，可以让单行文本垂直居中 */
	text-align:center; /* 居中对齐文字 */
	background:#3A4953; /* 设置背景色 */
	color:#fff; /* 设置文字颜色 */
	text-decoration:none; /* 去掉下划线 */
}
.list_head_li_a:HOVER{
	background:#146C9C; /* 变换背景色 */
	color:#fff; /* 变换文字颜色 */
	cursor: pointer;
}
.list_head_li_a.data{
	background:#146C9C;
}
</style>
<body class="bgray">
	<ul class="list_head_ul">
		<li class="list_head_li"><a class="list_head_li_a task" href="<%=basePath %>task/taskList/">任务列表</a></li>
		<li class="list_head_li"><a class="list_head_li_a api" href="<%=basePath %>api/apiList">接口列表</a></li>
		<li class="list_head_li"><a class="list_head_li_a data"  href="<%=basePath %>ddic/ddicList">数据字典</a></li>
	</ul>
	<form id="addForm" method="post">
		<table class="list_table">
			<thead>
				<tr>
					<th>ID</th>
					<th>名称</th>
					<th>类型</th>
					<th>部门名称</th>
					<th>部门编码</th>
					<th>栏目号</th>
					<th>栏目名称</th>
					<th>区域</th>
					<th>区域编码</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach var="data" items="${ddics}">
					<tr>
						<td>${data.dicId}</td>
						<td>${data.dicName}</td>
						<td>${data.dicType}</td>
						<td>${data.orgName}</td>
						<td>${data.orgCode}</td>
						<td>${data.channelId}</td>
						<td>${data.channelName}</td>
						<td>${data.region}</td>
						<td>${data.regionCode}</td>
						<td><a href="javascript:;" onclick="deleteDic('${data.dicId}')">删除</a></td>
					</tr>
				</c:forEach>
					<tr>
						<td><input type="text" name="dicId" id="dicId" value="0" readonly="readonly"></input></td>
						<td><input type="text" name="dicName" id="dicName" value=""></input></td>
						<td><input type="text" name="dicType" id="dicType" value=""></input></td>
						<td><input type="text" name="orgName" id="orgName" value=""></input></td>
						<td><input type="text" name="orgCode" id="orgCode" value=""></input></td>
						<td><input type="text" name="channelId" id="channelId" value=""></input></td>
						<td><input type="text" name="channelName" id="channelName" value=""></input></td>
						<td><input type="text" name="region" id="region" value=""></input></td>
						<td><input type="text" name="regionCode" id="regionCode" value=""></input></td>
						<td><input type="button" value="保存" onclick="addOne();"/></td>
					</tr>
			</tbody>
		</table>
	</form>
</body>
<script>
function deleteDic(dicId){
	if (confirm("删除任务！")) {
		showWaitMsg();
		$.ajax({
			type : "POST",
			async : false,
			dataType : "JSON",
			cache : false,
			url : "${basePath}ddic/delete",
			data : {
				dicId : dicId
			},
			success : function(data) {
				hideWaitMsg();
				if (data.flag) {
					alert(data.msg);
					location.reload();
				} else {
					alert(data.msg);
				}

			}//end-callback
		});//end-ajax
	}
}
function addOne(){
	console.log($("#addForm").serialize());
	$.ajax({
		type:"POST",
		async:false,
		dataType:"JSON",
		cache:false,
		url:"${basePath}ddic/add",
		data:$("#addForm").serialize(),
		success:function(data){
			if (data.flag) {
				alert(data.msg);
				location.reload();
			} else {
				alert(data.msg);
			}
		}
	});
}
function showWaitMsg(msg) {
	if (msg) {

	} else {
		msg = '正在处理，请稍候...';
	}
	var panelContainer = $("body");
	$("<div id='msg-background' class='datagrid-mask' style=\"display:block;z-index:10006;\"></div>").appendTo(panelContainer);
	var msgDiv = $("<div id='msg-board' class='datagrid-mask-msg' style=\"display:block;z-index:10007;left:50%\"></div>").html(msg).appendTo(
			panelContainer);
	msgDiv.css("marginLeft", -msgDiv.outerWidth() / 2);
}
function hideWaitMsg() {
	$('.datagrid-mask').remove();
	$('.datagrid-mask-msg').remove();
}
</script>
</html>




